package com.jcfk.eam.service.equ;

import com.alibaba.druid.util.StringUtils;
import com.jcfk.common.web.domain.DataPage;
import com.jcfk.common.web.domain.ReqPageParam;
import com.jcfk.eam.dao.equ.EquStatisticsDao;
import com.jcfk.eam.domain.dto.main.EamAssetInfoDTO;
import com.jcfk.eam.domain.dto.main.EquMtbfStatisticsDTO;
import com.jcfk.eam.domain.dto.main.EquMttrStatisticsDTO;
import com.jcfk.eam.domain.dto.main.EquStatisticsDTO;
import com.jcfk.eam.domain.query.main.EamAssetInfoQuery;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class EquStatisticsService{

    @Resource
    private EquStatisticsDao equStatisticsDao;
    public DataPage<EquMttrStatisticsDTO> mttrStatistics(DataPage<EquMttrStatisticsDTO> page, EquStatisticsDTO query) {

        query.setAssetCode(StringUtils.isEmpty(query.getAssetCode()) ? query.getAssetCode() : "%"+query.getAssetCode() + "%");
        query.setAssetName(StringUtils.isEmpty(query.getAssetName()) ? query.getAssetName() : "%"+query.getAssetName() + "%");
        page = equStatisticsDao.mttrStatistics(page, query);
        return page;
    }

    public DataPage<EquMtbfStatisticsDTO> mtbfStatistics(DataPage<EquMtbfStatisticsDTO> page, EquStatisticsDTO query) {
        query.setAssetCode(StringUtils.isEmpty(query.getAssetCode()) ? query.getAssetCode() : "%"+query.getAssetCode() + "%");
        query.setAssetName(StringUtils.isEmpty(query.getAssetName()) ? query.getAssetName() : "%"+query.getAssetName() + "%");
        page = equStatisticsDao.mtbfStatistics(page, query);
        return page;
    }
}
